home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 520 < prev    next >
Internet Message Format  |  1996-08-06  |  2KB

  1. Path: sdrc.com!thor!scjones
  2. From: larry.jones@sdrc.com (Larry Jones)
  3. Newsgroups: comp.std.c
  4. Subject: Re: Bit-field sizes
  5. Date: 7 Mar 1996 16:42:56 GMT
  6. Organization: SDRC Engineering Services
  7. Distribution: world
  8. Message-ID: <4hn3mg$c9v@info1.sdrc.com>
  9. References: <nzRPxQ9ytZZA084yn@csn.net> <4hkgds$bbh@info1.sdrc.com> <uYgPxQ9ytt9W084yn@csn.net>
  10. NNTP-Posting-Host: thor.sdrc.com
  11. Originator: scjones@thor
  12.  
  13. In article <4hkgds$bbh@info1.sdrc.com>, I wrote (quoting the standard):
  14. >
  15. >    The expression that specifies the width of a bit-field shall be
  16. >    an integral constant expression that nas nonnegative value that
  17. >    shall not exceed the number of bits in an ordinary object of
  18. >    compatible type.
  19.  
  20. In article <uYgPxQ9ytt9W084yn@csn.net>, thads@csn.net (Thad Smith) writes:
  21. > What does "ordinary object of compatible type" mean?  Could that mean
  22. > long?  I now think that an implementation could allow specification of
  23. > a number of bits greater than int, but less than or equal to bits in
  24. > long.  To access the value, the programmer casts the bit-field to long
  25. > or unsigned long.  The cast would preceed the integral promotion, I
  26. > think, and allow access to the longer value.
  27.  
  28. An ordinary object (i.e., not a bit-field) with the same type as the
  29. declared type of the bit-field which is required to be int, signed int,
  30. or unsigned int.  As Norm Diamond pointed out, that requirement is in
  31. semantics, not constraints, so an implementation is free to add an
  32. extension allowing other types (like long), and some do.  Such
  33. implementations presumably extend the integral promotion rules in the
  34. obvious fashion as well in order to eliminate the need for casts.
  35. ----
  36. Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH  45150-2789  513-576-2070
  37. larry.jones@sdrc.com
  38. Santa's gonna skip this block for years. -- Calvin
  39.